package com.qf.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.qf.feign.TestFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version v1.0.0
 * @Description:
 * @author: 姜红凯
 * @date: 2022.03.24
 * @since 1.0
 */
@RestController
//动态刷新从配置中心拉取的内容
@RefreshScope
public class CustomerController {
    @Autowired
    TestFeign testFeign;

    //读取从nacos配置中心服务中拉取的配置内容信息
    @Value("${version}")
    String version;

    /**
     * id是第一个参数，索引号是0,
     * name 是第二个参数，索引号是1
     * @param ia
     * @param name
     * @return
     * @throws Exception
     */
    @RequestMapping("/customer")
    @SentinelResource("/xxx")
    public String customerTest(String ia,String name)throws Exception{
        String str = testFeign.test();

        //慢调用比例
        //线程睡眠1000毫秒,也就是1秒
        //Thread.sleep(1000);

        //异常比例
       // int i = 1/0;

        return str + "=======version=" + version;
    }

}
